package com.example.yiqiuser.controller;

import com.example.yiqiuser.entity.SbsnOrder;
import com.example.yiqiuser.service.SbsnOrderService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ fileName:SbsnOrderController
 * @ description:
 * @ author:xjd
 * @ createTime:2023/4/1 9:05
 * @ version:1.0.0
 */
@RestController //相当于@Controller+@ResponseBody
@RequestMapping("sbsnorder") //页面先请求该路径,再往下找
public class SbsnOrderController extends BaseController {

    //依赖注入
    @Resource
    private SbsnOrderService sbsnOrderService;

    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<SbsnOrder> page){
        /*System.out.println("page信息：---------------"+page);*/
        return success(sbsnOrderService.queryByPage(page));
    }


    /**
     * 查询所有
     * @return
     */
    @GetMapping("queryAll")
    public Result queryAll(){
        return success(sbsnOrderService.queryAll());
    }

    /**
     * 根据Id添加
     * @param orderid
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(int orderid){
        return success(sbsnOrderService.queryById(orderid));
    }


    /**
     * 添加
     * @param sbsnOrder
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody SbsnOrder sbsnOrder){
        return success(sbsnOrderService.add(sbsnOrder));
    }


    /**
     * 更新
     * @param sbsnOrder
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody SbsnOrder sbsnOrder){
        return success(sbsnOrderService.update(sbsnOrder));
    }

    /**
     * 根据Id删除
     * @param orderid
     * @return
     */
    @DeleteMapping("deleteById")
    public Result deleteById(int orderid){//普通属性传参，不需要加@RequestBody
        return success(sbsnOrderService.deleteById(orderid));
    }


}
